Release 10.1A: OpenEdge Development:
Progress Dynamics Basic Development


Defining a custom super procedure

If you define dynamic, logical objects in your Progress Dynamics application, they exist only as records in the Repository database. Therefore, you have no source procedure where you can write custom code that is needed by the dynamic object. Progress Dynamics handles this situation by letting you define a custom procedure containing code needed by a dynamic object. This file is referred to as a custom super procedure because at run time it runs as a persistent procedure and is made a super procedure of the object it supports. In this way, any RUN statement done in the dynamic object will find the supporting code in the super procedure and execute it there. Because this toolbar example uses custom code to support some of its actions, one specific example of the technique is provided here.

To create the procedure where you can write the EditAction code:

  1. Create a new structured procedure in the AppBuilder. So that the procedure is registered in the Repository, specify an appropriate Product Module to be associated with it, as shown:
  2. In the wizard for the Structured Procedure, provide the name, description, and purpose for the procedure, which will be added to the comments section at the beginning of the procedure as internal documentation.
  3. When you complete the wizard, choose the Edit icon in the AppBuilder. This displays the AppBuilder’s Section Editor.
  4. Select Procedures from the Section drop-down list.
  5. Choose the New button to create a new procedure, providing EditAction as the name.
  6. The following code is for the EditAction procedure, which uses its input parameter (which you specified when you defined the actions for the Cut, Copy, and Paste items in the Menu and Toolbar Designer) to handle all three operations:

    /*--------------------------------------------------------------------- 
      Purpose:   Perform cut/copy/paste operations    
      Parameters:  pcAction = "Cut", "Copy", or "Paste" 
      Notes:        
    --------------------------------------------------------------------*/ 
    DEFINE INPUT  PARAMETER pcAction AS CHARACTER  NO-UNDO. 
    DEFINE VARIABLE lTextSelected AS LOGICAL    NO-UNDO. 
    DEFINE VARIABLE lOK           AS LOGICAL    NO-UNDO. 
    CASE pcAction: 
        WHEN "Cut":U THEN 
        DO: 
            lTextSelected = FOCUS:TEXT-SELECTED NO-ERROR. 
            IF lTextSelected THEN 
            DO: 
                lOK = FOCUS:EDIT-CUT() NO-ERROR. 
                IF lOK THEN 
                    APPLY "VALUE-CHANGED":U TO FOCUS. 
            END. 
        END. 
        WHEN "Copy":U THEN 
        DO: 
            IF FOCUS:TEXT-SELECTED THEN 
                lOK = FOCUS:EDIT-COPY() NO-ERROR. 
        END. 
        WHEN "Paste":U THEN 
        DO: 
            IF FOCUS:EDIT-CAN-PASTE THEN 
            DO: 
                lOK = FOCUS:EDIT-PASTE() NO-ERROR. 
                IF lOK THEN 
                    APPLY "VALUE-CHANGED":U TO FOCUS. 
            END. 
        END. 
    END CASE. 
    END PROCEDURE. 
    

  7. Enter this code and save your procedure where it will be found in your Propath.
  8. Open your dynamic window (custfoldwin or whatever window you are using) using the Open Object dialog box again.
  9. Enter the name of your procedure (including a relative pathname if needed) in the field labeled Custom ADD-SUPER-PROC.
  10. Note: You are associating the procedure with the window, not directly with the toolbar. This is because toolbar item actions that run internal procedures look for them in the container, not in the toolbar object itself, if there is no specific action link to another object.

  11. Save the dynamic window and relaunch it (or the browse window that precedes it) via the Dynamic Launcher. Now you will see the Cut, Copy, and Paste items enabled (both as menu items and as toolbar buttons), and you can use them to edit, for example, the Comments field for the Customer.

Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095